function compressed = linearRangeCompression(X)
    isColor = size(size(X),2) > 2;
    if (isColor)
        % Ver si existe una manera de procesar todo por igual sea a color o
        % no. Se hacia dificil el manejo de la matrix de (r,c,3)
        % row,col,RGBpixels.
        [r, c] = size(X(:,:,1));
        compressed = uint8(zeros(r,c,3));
        r = double(X(:,:,1));
        g = double(X(:,:,2));
        b = double(X(:,:,3));
        max0 = [max(r(:)), max(g(:)), max(b(:))];
        min0 = [min(r(:)), min(g(:)), min(b(:))];
        c1 = (255 ./ (max0 - min0));
        r = uint8(floor(c1(1)*r - min0(1)));
        g = uint8(floor(c1(2)*g - min0(2)));
        b = uint8(floor(c1(3)*b - min0(3)));
        compressed(:,:,1) = r;
        compressed(:,:,2) = g;
        compressed(:,:,3) = b;
    else
        max0 = max((double(X(:))));
        min0 = min((double(X(:))));
        c1 = (255 / (max0 - min0));
        compressed = uint8(floor(c1 * double(X) - min0));
    end
end
